package com.personal.controller.icp;

import com.github.pagehelper.PageInfo;
import com.personal.entity.icp.AltcItem;
import com.personal.service.icp.AltcItemService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.annotation.Resource;
import java.util.List;

@Api("设备信息API")
@RestController
@RequestMapping("/altcItem")
@Slf4j
public class AltcItemController {


    @Resource
    private AltcItemService itemService;

    @Resource
    private StringRedisTemplate reidsClient;

    @Value("${pay_money}")
    private String payMoney;

    @ApiIgnore
    @RequestMapping(value = "index", method = RequestMethod.GET)
    public String getIndedx(){
        reidsClient.opsForValue().set("springboot","springBootVal");
        return "index"+payMoney;
    }

    @ApiOperation(value = "获取所有设备信息", notes = "查询数据库所有设备信息")
    @RequestMapping(value = "/getAll", method = RequestMethod.GET)
    public List<AltcItem> getAll(){
        return itemService.getAll();
    }

    @ApiOperation(value = "分页查询设备", notes = "数据库设备分页查询")
    @RequestMapping(value = "/getPage", method = RequestMethod.GET)
    public PageInfo<AltcItem> getAllByPage(@RequestParam("page") Integer page, @RequestParam("pageSize") Integer pageSize){
        return itemService.getAllByPage(page, pageSize);
    }
}
